package com.sg.service.biz.app.nb;

import cn.hutool.core.bean.BeanUtil;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.biz.app.req.*;
import com.sg.dto.biz.app.res.*;
import com.wicket.okrapp.common.baseinfo.BaseInfoDO;
import com.wicket.okrapp.common.baseinfo.BaseInfoHolder;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

/**
 * @author ： 手工接入方法
 * @version 1.0
 * @since 2022/5/28 15:32
 */
@Service
public class NbMessage {
    /**
     * code:receptionService
     * name:M3接收圈子成员出参数据集
     * desc:undefined
     * gen by moon at 8/1/2023, 9:30:10 PM
     **/
    @Trace(operationName = "M3接收圈子成员出参数据集")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementGainInParameterFieldsRespDto implementGainInParameterFields(ImplementGainInParameterFieldsReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementGainInParameterFieldsRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3约定评价模板主体变更日志类型等字段
     * desc:undefined
     * gen by moon at 8/1/2023, 9:30:52 PM
     **/
    @Trace(operationName = "M3约定评价模板主体变更日志类型等字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementAcceptFieldRespDto implementAcceptField(ImplementAcceptFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementAcceptFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:M3-接收入参字段
     * desc:undefined
     * gen by moon at 11/8/2023, 3:55:47 PM
     **/
    @Trace(operationName = "M3-接收入参字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementAcceptFieldByStandardDataRespDto implementAcceptFieldByStandardData(ImplementAcceptFieldByStandardDataReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementAcceptFieldByStandardDataRespDto.class);
    }

    /**
     * code:objectToData
     * name:M执行图片多条转数据集
     * desc:undefined
     * gen by moon at 11/11/2023, 2:09:04 AM
     **/
    @Trace(operationName = "M执行图片多条转数据集")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementPicMultipleSetDataEntryRespDto implementPicMultipleSetDataEntry(ImplementPicMultipleSetDataEntryReqDto reqDto) {
        ImplementPicMultipleSetDataEntryRespDto retData = new ImplementPicMultipleSetDataEntryRespDto();
        if (reqDto.getPicMultipleSetDataEntryList() == null || reqDto.getPicMultipleSetDataEntryList().size() <= 0) {
            return retData;
        }
        for (PicMultipleSetDataEntryDto oneSrc : reqDto.getPicMultipleSetDataEntryList()) {
            if (oneSrc.getDatasetField() != null && !oneSrc.getDatasetField().isEmpty()) {
                String[] fileListSplit = oneSrc.getDatasetField().split(",");
                if (fileListSplit != null && fileListSplit.length > 0) {
                    for (String oneFile : fileListSplit) {
                        if (oneFile.equals("--")) {
                            continue;
                        }
                        PicMultipleSetDataEntryDto elm = new PicMultipleSetDataEntryDto();
                        elm.setCycleStageDataId(oneSrc.getCycleStageDataId());
                        elm.setDatasetPrimarykey(CommonFunctionHelper.getFilePath(oneFile));
                        retData.getPicMultipleSetDataEntryList().add(elm);
                    }
                }
            }
        }
        return retData;
    }

    /**
     * code:receptionService
     * name:M3-接收入参字段
     * desc:undefined
     * gen by moon at 11/15/2023, 2:05:31 AM
     **/
    @Trace(operationName = "M3-接收入参字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementTypeCodeFieldsAcceptRespDto implementTypeCodeFieldsAccept(ImplementTypeCodeFieldsAcceptReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementTypeCodeFieldsAcceptRespDto.class);
    }

    /**
     * code:receptionService
     * name:M2-约定问题的位置标识
     * desc:undefined
     * gen by moon at 12/13/2023, 2:20:10 AM
     **/
    @Trace(operationName = "M2-约定问题的位置标识")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainReceiveFieldsRespDto obtainReceiveFields(ObtainReceiveFieldsReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ObtainReceiveFieldsRespDto.class);
    }

    /**
     * code:publicFieldCache
     * name:M3公共字段推送内存
     * desc:undefined
     * gen by moon at 12/22/2023, 12:09:47 AM
     **/
    @Trace(operationName = "M3公共字段推送内存")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizPublicFieldPushMemoryRespDto implementBizPublicFieldPushMemory(ImplementBizPublicFieldPushMemoryReqDto reqDto) {
        BaseInfoDO domain = new BaseInfoDO();
        if (BaseInfoHolder.contextHolder.get() != null) {
            BeanUtil.copyProperties(BaseInfoHolder.contextHolder.get().getBaseInfo(), domain);
            BaseInfoHolder.contextHolder.remove();
        }
        if (reqDto.getSpaceId() != null) {
            domain.setSpecSpaceId(reqDto.getSpaceId());
        }

        if (reqDto.getCreateInductionId() != null) {
            domain.setSpecInductionRecordId(reqDto.getCreateInductionId());
        }

        if (reqDto.getAppId() != null) {
            domain.setSpecAppId(reqDto.getAppId());
        }

        if (reqDto.getHighestOrgID() != null) {
            domain.setSpecHighestOrgID(reqDto.getHighestOrgID());
        }

        if (reqDto.getUserId() != null) {
            domain.setSpecUserId(reqDto.getUserId());
        }

        if (reqDto.getOriginalRoleMemberId() != null) {
            domain.setSpecOriginalRoleMemberId(reqDto.getOriginalRoleMemberId());
        }

        CommonFunctionHelper.setBaseInfoToLocal(domain);
        return new ImplementBizPublicFieldPushMemoryRespDto();
    }

    /**
     * code:receptionService
     * name:出参：消息发送发信息
     * desc:undefined
     * gen by moon at 12/29/2023, 7:19:01 PM
     **/
    @Trace(operationName = "出参：消息发送发信息")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementSendMsgReceiverAcceptFieldRespDto implementSendMsgReceiverAcceptField(ImplementSendMsgReceiverAcceptFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementSendMsgReceiverAcceptFieldRespDto.class);
    }

    /**
     * code:receptionService
     * name:约定：否
     * desc:undefined
     * gen by moon at 1/1/2024, 9:14:19 PM
     **/
    @Trace(operationName = "约定：否")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementAcceptFieldUseWorkTaskRespDto implementAcceptFieldUseWorkTask(ImplementAcceptFieldUseWorkTaskReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementAcceptFieldUseWorkTaskRespDto.class);

    }

    /**
     * code:receptionService
     * name:约定：否
     * desc:undefined
     * gen by moon at 1/2/2024, 8:25:53 AM
     **/
    @Trace(operationName = "约定：否")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementFourthReceivingFieldRespDto implementFourthReceivingField(ImplementFourthReceivingFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementFourthReceivingFieldRespDto.class);
    }
    //手工接入方法
}
